package com.first.teacher.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.first.common.pojo.EduCourse;
import com.first.common.pojo.EduSubject;
import com.first.common.pojo.EduTeacher;
import com.first.common.vo.Result;
import com.first.teacher.service.SubjectService;
import com.first.teacher.service.TeacherService;
import com.first.teacher.vo.ChangeStatusVo;
import com.first.teacher.vo.FIndTeacherCourseVo;
import com.first.teacher.vo.FindCourseVo;
import com.first.teacher.vo.UpdateCourseSubjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: finrsteducation-parent
 * @description:
 * @author: 张玉森
 * @create: 2023-06-02 19:56
 **/
@RestController
@RequestMapping("/core/course")
@Api(tags = "课程中心查询")
public class EduSubjectController {
    @Autowired
    private SubjectService subjectService;
    @Autowired
    private TeacherService teacherService;



    @PostMapping("updateCourseSubject")
    @ApiOperation("修改课程信息")
    public Result updateCourseSubject(@RequestBody UpdateCourseSubjectVo updateCourseSubjectVo){
        Object update= subjectService.updateCourseSubject(updateCourseSubjectVo);
        return Result.success(update);
    }

    @PostMapping("fontFindCourse/{page}/{pageSize}")
    @ApiOperation("查询所有课程")
    private Result fontFindCourse(@PathVariable Integer page,
                                  @PathVariable Integer pageSize,
                                  @RequestBody FindCourseVo findCourseVo) {
        Page<EduCourse> course = subjectService.fontfindCourse(page, pageSize, findCourseVo);

        return Result.success(course);
    }

    @PostMapping("changeStatus")
    @ApiOperation("请求更新课程上下架状态方法")
    public Result changeStatus(@RequestBody ChangeStatusVo changeStatusVo) {
        Integer integer = subjectService.changeStatus(changeStatusVo);
        return Result.success(integer);
    }

    @PostMapping("getAllMenu")
    @ApiOperation("课程中心数据数量查询")
    public Result getAllMenu() {
        List<EduSubject> list = subjectService.getAllMenu();
        return Result.success(list);
    }

    @GetMapping("findTeacherByTeacherId/{teacherId}")
    @ApiOperation("获取讲师课程信息")
    public Result findTeacherByTeacherId(@PathVariable String teacherId) {
        EduTeacher eduTeacher = teacherService.findTeacherByTeacherId(teacherId);
        return Result.success(eduTeacher);
    }

    @PostMapping("findCourseByTeacherId/{page}/{pageSize}")
    @ApiOperation("课程中心数据数量查询")
    public Result findCourseByTeacherId(@PathVariable Integer page,
                                        @PathVariable Integer pageSize,
                                        @RequestBody FIndTeacherCourseVo teacherCourseVo) {
        System.out.println(teacherCourseVo);
        Page<EduCourse> courseByTeacherId = subjectService.findCourseByTeacherId(page, pageSize, teacherCourseVo);
        return Result.success(courseByTeacherId);
    }

    @GetMapping("getCoursByTeacherPhone/{page}/{pageSize}/{phone}/{checkStatus}")
    @ApiOperation("录播管理全部表格显示")
    public Result getCoursByTeacherPhone(@PathVariable Integer page,
                                         @PathVariable Integer pageSize,
                                         @PathVariable String phone,
                                         @PathVariable Integer checkStatus) {
        Page<EduCourse> list = subjectService.getCoursByTeacherPhone(page, pageSize, phone, checkStatus);
        return Result.success(list);
    }
}
